﻿
@{
    ViewData["Title"] = "Add";
    Layout = "~/Areas/Admin/Views/_Layout.cshtml";
}
<link href="~/lib/layui-select/formSelects-v4.css" rel="stylesheet" />
<div style="margin-top:3em;margin-right:5em">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">项目类型</label>
            <div class="layui-input-block">
                <input type="text" name="Name" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-form-item">
                <label class="layui-form-label">组织</label>
                <div class="layui-input-block">
                    <select name="TypeIds" id="TypeIds" xm-select="TypeIds" xm-select-search=""></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
    //全局定义一次, 加载formSelects
    layui.config({
        base: '/lib/layui-select/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4'
    });
    //Demo
    layui.use(['form', 'formSelects'], function () {
        var form = layui.form;
        var formSelects = layui.formSelects;
        $.get("/project/projecttype/getdata",function(repo){
            var html = '';
            $.each(repo.data, function (index, item) {
                html += '<option value="' + item.name + '">' + item.value + '</option>';
            });
            $("#TypeIds").html(html);
            formSelects.render();
        });
        //监听提交
        form.on('submit(formDemo)', function (data) {
            BaseAjax(ajaxType.post, "/project/projecttype/add",data.field, function (repo){
                x_admin_close();
            })
            return false;
        });
    });
</script>

